package p.ithorns.sample.refresh;

import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.util.ClassUtils;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * CustomizeConfigContextInitializer
 * TODO
 *
 * @author HtL
 * @date 2025/3/14 14:34
 * @since 1.0.0
 */
public class CustomizeConfigContextInitializer
        implements ApplicationContextInitializer<ConfigurableApplicationContext> {

    ConfigurableApplicationContext appCtx;


    @Override
    public void initialize(ConfigurableApplicationContext appCtx) {
        this.appCtx = appCtx;
        ConfigurableEnvironment env = appCtx.getEnvironment();
        MutablePropertySources propertySources = env.getPropertySources();
        propertySources.addFirst(new MapPropertySource("refreshProps", ConfigContext.getConfigs()));
    }

}